//
//  HMShoppingCarBtn.m
//  HowToDo
//
//  Created by 宋轩 on 17/1/9.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMShoppingCarBtn.h"
#import "HMShoppingCarTool.h"

@implementation HMShoppingCarBtn

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)init
{
    if (self = [super init])
    {
        [self createBtn];
        
    }
    return self;
}

- (void)createBtn
{
    [self setImage:[UIImage imageNamed:@"add_tochat_btn"] forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:@"add_tochat_btn_incar_44x44_"] forState:UIControlStateSelected];
    [self addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
}

//点击购物车
- (void)btnClick:(UIButton *)btn
{
    if (btn.selected) {
        
        btn.selected = NO;
        
        [[HMShoppingCarTool sharedShoppingCarTool] removeShoppingCarDataWithID:self.resource_id];
    }
    else
    {
        btn.selected = YES;
        [[HMShoppingCarTool sharedShoppingCarTool] getShoppingCarDataWithID:self.resource_id andImageUrl:self.image_url andName:self.resource_name andContent:self.resource_content andEnclosure:self.resource_enclosure andPrice:self.price];
        
    }
}

- (void)setResource_name:(NSString *)resource_name {
    
    _resource_name = resource_name;
    
    
}




@end
